{
    class RectCheckBox {
        constructor(option) {
            let selector;
            this.selector = selector = document.querySelector(option.selector);
            let checkBoxInputNodeList = selector.querySelectorAll("input");
            for (let i = 0; i <= checkBoxInputNodeList.length - 1; i++) {
                checkBoxInputNodeList[i].style.display = "none";
            }

            let checkBoxLableNodeList = selector.querySelectorAll("label"); 
            for (let i = 0; i <= checkBoxLableNodeList.length - 1; i++) {
                if (checkBoxLableNodeList[i].querySelector("input").checked) {
                    checkBoxLableNodeList[i].querySelector("input").checked = true;
                    this._changeStyle(checkBoxLableNodeList[i], true);
                } else {
                    checkBoxLableNodeList[i].querySelector("input").checked = false;
                    this._changeStyle(checkBoxLableNodeList[i], false);
                }
                checkBoxLableNodeList[i].style.cursor = "pointer";
                checkBoxLableNodeList[i].style.paddingLeft = "10px";
                checkBoxLableNodeList[i].style.paddingRight = "10px";
                checkBoxLableNodeList[i].style.fontSize = "14px";
            }

            selector.onclick = (e) => {
                if (e.target.tagName === "LABEL") {
                    if (e.target.querySelector('input').checked) {
                        this._changeStyle(e.target, false);
                    } else {
                        this._changeStyle(e.target, true);
                    } 
                }
            };

        }

        _changeStyle(dom, bool) {
            if (bool) {
                dom.style.backgroundColor = "#00c0ef";
                dom.style.color = "#fff"; 
            } else {
                dom.style.backgroundColor = "transparent";
                dom.style.color = "#000";
            }
        }

        getValue() {
            let valueArr = [];
            let inputNodeList = this.selector.querySelectorAll("input");
            for (let i = 0; i <= inputNodeList.length - 1; i++) {
                if (inputNodeList[i].checked) {
                    valueArr.push(inputNodeList[i].value);
                }
            }
            return valueArr;
        }

        setValue(valueArr) {
            let inputNodeList = this.selector.querySelectorAll("input");
            valueArr.forEach((val) => { 
                for (let i = 0; i <= inputNodeList.length - 1; i++) { 
                    if ( val == inputNodeList[i].value ) { 
                        inputNodeList[i].checked = true; 
                        this._changeStyle(inputNodeList[i].parentNode, true);
                    }
                }
            });
        }
    }

    if (!window.RectCheckBox) window.RectCheckBox = RectCheckBox;
}
